// 页面路径：store/index.js 
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);//vue的插件机制

//Vuex.Store 构造器选项
const store = new Vuex.Store({
    state: {//存放状态
        appUpdate: false,//当前是否有新的APP包需要更新
        preserve: false,//当前是否在维护中

        deviceType: '',//h5、ios、android  

        isWxMiniRecharge: false,//是否app调用微信小程序进行支付
        isZfbRecharge: false,//是否app调用外部浏览器打开支付宝进行支付

        isOnline: 1,//1正常  2线上包

        configList: '',//配置内容
    },
    mutations: {
        _appUpdate(state, data) {
            state.appUpdate = data;
        },
        _preserve(state, data) {
            state.preserve = data;
        },
        _deviceType(state, data) {
            state.deviceType = data;
        },
        _isWxMiniRecharge(state, data) {
            state.isWxMiniRecharge = data;
        },
        _isZfbRecharge(state, data) {
            state.isZfbRecharge = data;
        },
        _isOnline(state, data) {
            state.isOnline = data;
        },
        _configList(state, data) {
            state.configList = data;
        }
    },
    actions: {
        setAppUpdate(context, data) {
            context.commit('_appUpdate', data);
        },
        setPreserve(context, data) {
            context.commit('_preserve', data);
        },
        setDeviceType(context, data) {
            context.commit('_deviceType', data);
        },
        setIsWxMiniRecharge(context, data) {
            context.commit('_isWxMiniRecharge', data);
        },
        setIsZfbRecharge(context, data) {
            context.commit('_isZfbRecharge', data);
        },
        setIsOnline(context, data) {
            context.commit('_isOnline', data);
        },
        setConfigList(context, data) {
            context.commit('_configList', data);
        }
    }
})
export default store